// Copyright 2008 Senary
// See credits.txt for details.

// This file is part of Omega VII.

// Omega VII is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Omega VII is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Omega VII.  If not, see <http://www.gnu.org/licenses/>.

#pragma once
#define COSTFACTORY 120
#define COSTMINE 90

#include "Combatunit.h"
#include "Spaceship.h"

enum PlanetType{
	PT_OMEGA_VII,
	PT_EPLAX,
	PT_KYAUYU,
	PT_OPA_QUARTUS,
	PT_OYCH,
	PT_RYOULAG,
	PT_TUN_DOUAARI,

	PT_NUMPLANETTYPES
};

class Planet : public CombatUnit
{
private:
	PlanetType _type;

	float FactoriesLand;		//Amount of Factory land left
	float MinesLand;			//Amount of Mine land left
	float FreeLand;			//Amount of Free land left
	float ResourceLand;		//Amount of land with resources
	float ConstructionPoint;	//No. of Constuction Points left
	float m_totaltime;
	float upkeep;

public:
	Planet(PlanetType type);
	~Planet(void);

	//constant values (depend only on type)
	virtual int maxFirepower() const; // inherited from CombatUnit
	virtual int maxShield() const; // inherited from CombatUnit
	int maxPopulation(void) const;
	int resourceDistribution(void) const;
	int numDaysPerYear(void) const;
	double orbitHeight(void) const;

	//properties
	float getConstructionPoint(void) const;

	//operations
//	int setLandRatio(float factorypercent, float minespercent);


	int buildFactory(int size);
	int buildMine(int size);
	int orderSpaceship(int quantity, SpaceshipType type);
	
//	int destroyFactory(int size);
//	int destroyMine(int size);
//	int cancelOrder(Spaceship type);
	
//	int numSpaceshipBuilt(void);
//	Spaceship* getBuiltSpaceship(void);
	
	void update(float timestep, float totalTime);

	// Checks if the planet collides with another object
	//virtual bool isColliding(SpaceObject const& other) const;
	virtual bool isInRange(SpaceObject const& other) const;

	// Inherited from SpaceObject
	virtual void setOwner(Player * owner);

	// Inherited from CombatUnit
	// Receive a certain amount of damage
	// param damager: the unit that inflicts the damage.
	void receiveDamage(double damage, CombatUnit* damager, float totalTime);


	float getFactoriesLand();		//Amount of Factory land left
	float getMinesLand();			//Amount of Mine land left
	float getFreeLand();			//Amount of Free land left
	float getResourceLand();		//Amount of land with resources
	float getConstructionPoint();	//No. of Constuction Points left

	void setFactoriesLand(float fLand);		//Amount of Factory land left
	void setMinesLand(float mLand);			//Amount of Mine land left
	void setFreeLand(float frLand);			//Amount of Free land left
	void setResourceLand(float rLand);		//Amount of land with resources
	void setConstructionPoint(float cp);	//No. of Constuction Points left

	// Convert a string to planetType
	static PlanetType planetTypeFromString(std::string s);

	// Convert a planetType to string
	static std::string stringFromPlanetType(PlanetType pt);
};
